﻿using ACC.Business;
using ACC.Business.Stn;
using ACC.Data;
using ACC.Data.ACCLog;
using ACC.Data.Comm;
using ACC.Data.Entities.Mes;
using ACC.Data.Line;
using ACC.Device;
using ACC.LineDevice.KukaPack;
using System;
using System.Collections.Generic;
using System.Linq;


namespace Script
{
    /// <summary>
    /// 电芯等离子清洗
    /// OP L1M02030, STATION L1M12031, L1M12032, L1M22031, L1M22032
    /// </summary>
    public class L1M02030 : StnProcessPL02_DX
    {
        public L1M02030(StnRunningData data)
            : base(data)
        {
            IsReport = false;
            IsACCReport = false;
            IsPalletRelationSN = false;
        }

        protected override ACCDevice CreateDevice()
        {
            ACCDevice dev = base.CreateDevice();
            if (kukaSiemensDev != null)
            {
                switch (_data.StnCfg.Name)
                {
                    case "L1M12031":
                    case "L1M22031":
                        {
                            kukaSiemensDev.DB190_Offset = 2000;

                        }
                        break;
                    case "L1M12032":
                    case "L1M22032":
                        {
                            kukaSiemensDev.DB190_Offset = 5000;
                        }
                        break;
                }

                kukaSiemensDev.DB190 = 800;
                //kukaSiemensDev.DB190_Offset = 2000;
                kukaSiemensDev.DB192 = 80;
                kukaSiemensDev.DB192_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 290);
                kukaSiemensDev.DB193 = 800;
                kukaSiemensDev.DB193_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 66);
                kukaSiemensDev.DB193_ACC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 68);
                kukaSiemensDev.DB194 = 800;
                kukaSiemensDev.DB194_PLC_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 66);
                kukaSiemensDev.DB194_PLC_Data_Offset = (ushort)(kukaSiemensDev.DB190_Offset + 302);

                kukaSiemensDev.BarcodeLength = 30;
                kukaSiemensDev.LoadBarcodeCount = 6;
                kukaSiemensDev.UnloadBarcodeCount = 6;

                kukaSiemensDev.Material_COMM_Offset = 292;       // 上下料信号位偏移量
            }

            return dev;

        }

        protected override void CreateBusinessLogic()
        {
            base.CreateBusinessLogic();

            (_loadProcess as LoadProcess_DX).R = 3;
            (_unloadProcess as UnloadProcess_DX).R = 3;
            (_unloadProcess as UnloadProcess_DX).OneAsNG = true;
        }
    }
}